package org.boot;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.scheduling.annotation.EnableAsync;

import java.util.concurrent.atomic.AtomicReference;


@SpringBootApplication
@EnableCaching
@EnableAsync
//@SpringBootConfiguration(proxyBeanMethods = false)
//@EnableAutoConfiguration
//@Import({ SomeConfiguration.class, AnotherConfiguration.class })
public class MyBoot implements ApplicationRunner {

    private static final Logger logger = LoggerFactory.getLogger(MyBoot.class);

    public static void main(String[] args) {
//        SpringApplication.run(MyBoot.class, args);
        SpringApplication application = new SpringApplication(MyBoot.class);
        application.setApplicationStartup(new BufferingApplicationStartup(2048));
        application.setBanner(getBanner());
        application.run(args);
    }

    private static Banner getBanner() {
        Resource resource = new ClassPathResource("banner.txt");
        AtomicReference<Banner> banner = new AtomicReference<>(new ResourceBanner(resource));
        return banner.get();
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        logger.info("=================================启动成功=================================启动成功=================================");
    }
}